package org.altervista.cp.thinjdbc.wrappers;

import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.Ref;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Map;

import org.altervista.cp.thinjdbc.util.LogHelper;

public abstract class ResultSet extends Wrapper<java.sql.ResultSet>
		implements java.sql.ResultSet {

	private static final LogHelper logger = new LogHelper(
			ResultSet.class);

	static ResultSet newInstance(java.sql.ResultSet rs) {
		return _GENERATOR.generate(rs);
	}

	public void close() {
		try {
			java.sql.ResultSet rs = unwrap();
			if (rs != null) {
				logger.debug("closing resultset");
				rs.close();
			}
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		} finally {
			if (_rsmdw != null) {
				_rsmdw.close();
				_rsmdw = null;
			}
			_sw = null;
			_GENERATOR.release(this);
		}
	}

	public Statement getStatement() {
		return _sw;
	}

	public ResultSetMetaData getMetaData() {
		try {
			if (_rsmdw == null) {
				_rsmdw = ResultSetMetaData.newInstance(unwrap().getMetaData());
			}
			return _rsmdw;
		} catch (SQLException e) {
			throw new SQLRuntimeException(e);
		}
	}

	public abstract boolean absolute(int row);

	public abstract void afterLast();

	public abstract void beforeFirst();

	public abstract void cancelRowUpdates();

	public abstract void clearWarnings();

	public abstract void deleteRow();

	public abstract int findColumn(String columnName);

	public abstract boolean first();

	public abstract Array getArray(int i);

	public abstract Array getArray(String colName);

	public abstract InputStream getAsciiStream(int columnIndex);

	public abstract InputStream getAsciiStream(String columnName);

	public abstract BigDecimal getBigDecimal(int columnIndex, int scale);

	public abstract BigDecimal getBigDecimal(int columnIndex);

	public abstract BigDecimal getBigDecimal(String columnName, int scale);

	public abstract BigDecimal getBigDecimal(String columnName);

	public abstract InputStream getBinaryStream(int columnIndex);

	public abstract InputStream getBinaryStream(String columnName);

	public abstract Blob getBlob(int i);

	public abstract Blob getBlob(String colName);

	public abstract boolean getBoolean(int columnIndex);

	public abstract boolean getBoolean(String columnName);

	public abstract byte getByte(int columnIndex);

	public abstract byte getByte(String columnName);

	public abstract byte[] getBytes(int columnIndex);

	public abstract byte[] getBytes(String columnName);

	public abstract Reader getCharacterStream(int columnIndex);

	public abstract Reader getCharacterStream(String columnName);

	public abstract Clob getClob(int i);

	public abstract Clob getClob(String colName);

	public abstract int getConcurrency();

	public abstract String getCursorName();

	public abstract Date getDate(int columnIndex, Calendar cal);

	public abstract Date getDate(int columnIndex);

	public abstract Date getDate(String columnName, Calendar cal);

	public abstract Date getDate(String columnName);

	public abstract double getDouble(int columnIndex);

	public abstract double getDouble(String columnName);

	public abstract int getFetchDirection();

	public abstract int getFetchSize();

	public abstract float getFloat(int columnIndex);

	public abstract float getFloat(String columnName);

	public abstract int getInt(int columnIndex);

	public abstract int getInt(String columnName);

	public abstract long getLong(int columnIndex);

	public abstract long getLong(String columnName);

	public abstract Object getObject(int i, Map<String, Class<?>> map);

	public abstract Object getObject(int columnIndex);

	public abstract Object getObject(String colName, Map<String, Class<?>> map);

	public abstract Object getObject(String columnName);

	public abstract Ref getRef(int i);

	public abstract Ref getRef(String colName);

	public abstract int getRow();

	public abstract short getShort(int columnIndex);

	public abstract short getShort(String columnName);

	public abstract String getString(int columnIndex);

	public abstract String getString(String columnName);

	public abstract Time getTime(int columnIndex, Calendar cal);

	public abstract Time getTime(int columnIndex);

	public abstract Time getTime(String columnName, Calendar cal);

	public abstract Time getTime(String columnName);

	public abstract Timestamp getTimestamp(int columnIndex, Calendar cal);

	public abstract Timestamp getTimestamp(int columnIndex);

	public abstract Timestamp getTimestamp(String columnName, Calendar cal);

	public abstract Timestamp getTimestamp(String columnName);

	public abstract int getType();

	public abstract InputStream getUnicodeStream(int columnIndex);

	public abstract InputStream getUnicodeStream(String columnName);

	public abstract URL getURL(int columnIndex);

	public abstract URL getURL(String columnName);

	public abstract SQLWarning getWarnings();

	public abstract void insertRow();

	public abstract boolean isAfterLast();

	public abstract boolean isBeforeFirst();

	public abstract boolean isFirst();

	public abstract boolean isLast();

	public abstract boolean last();

	public abstract void moveToCurrentRow();

	public abstract void moveToInsertRow();

	public abstract boolean next();

	public abstract boolean previous();

	public abstract void refreshRow();

	public abstract boolean relative(int rows);

	public abstract boolean rowDeleted();

	public abstract boolean rowInserted();

	public abstract boolean rowUpdated();

	public abstract void setFetchDirection(int direction);

	public abstract void setFetchSize(int rows);

	public abstract void updateArray(int columnIndex, Array x);

	public abstract void updateArray(String columnName, Array x);

	public abstract void updateAsciiStream(int columnIndex, InputStream x,
			int length);

	public abstract void updateAsciiStream(String columnName, InputStream x,
			int length);

	public abstract void updateBigDecimal(int columnIndex, BigDecimal x);

	public abstract void updateBigDecimal(String columnName, BigDecimal x);

	public abstract void updateBinaryStream(int columnIndex, InputStream x,
			int length);

	public abstract void updateBinaryStream(String columnName, InputStream x,
			int length);

	public abstract void updateBlob(int columnIndex, Blob x);

	public abstract void updateBlob(String columnName, Blob x);

	public abstract void updateBoolean(int columnIndex, boolean x);

	public abstract void updateBoolean(String columnName, boolean x);

	public abstract void updateByte(int columnIndex, byte x);

	public abstract void updateByte(String columnName, byte x);

	public abstract void updateBytes(int columnIndex, byte[] x);

	public abstract void updateBytes(String columnName, byte[] x);

	public abstract void updateCharacterStream(int columnIndex, Reader x,
			int length);

	public abstract void updateCharacterStream(String columnName,
			Reader reader, int length);

	public abstract void updateClob(int columnIndex, Clob x);

	public abstract void updateClob(String columnName, Clob x);

	public abstract void updateDate(int columnIndex, Date x);

	public abstract void updateDate(String columnName, Date x);

	public abstract void updateDouble(int columnIndex, double x);

	public abstract void updateDouble(String columnName, double x);

	public abstract void updateFloat(int columnIndex, float x);

	public abstract void updateFloat(String columnName, float x);

	public abstract void updateInt(int columnIndex, int x);

	public abstract void updateInt(String columnName, int x);

	public abstract void updateLong(int columnIndex, long x);

	public abstract void updateLong(String columnName, long x);

	public abstract void updateNull(int columnIndex);

	public abstract void updateNull(String columnName);

	public abstract void updateObject(int columnIndex, Object x, int scale);

	public abstract void updateObject(int columnIndex, Object x);

	public abstract void updateObject(String columnName, Object x, int scale);

	public abstract void updateObject(String columnName, Object x);

	public abstract void updateRef(int columnIndex, Ref x);

	public abstract void updateRef(String columnName, Ref x);

	public abstract void updateRow();

	public abstract void updateShort(int columnIndex, short x);

	public abstract void updateShort(String columnName, short x);

	public abstract void updateString(int columnIndex, String x);

	public abstract void updateString(String columnName, String x);

	public abstract void updateTime(int columnIndex, Time x);

	public abstract void updateTime(String columnName, Time x);

	public abstract void updateTimestamp(int columnIndex, Timestamp x);

	public abstract void updateTimestamp(String columnName, Timestamp x);

	public abstract boolean wasNull();

	void setStatementWrapper(Statement sw) {
		_sw = sw;
	}

	private Statement _sw;
	private ResultSetMetaData _rsmdw;

	private static final _ProxyGenerator<ResultSet> _GENERATOR = new _ProxyGenerator<ResultSet>(
			ResultSet.class);

}
